
let blue = new URL('../../mock/img/blue.png', import.meta.url).href
let green = new URL('../../mock/img/green.png', import.meta.url).href
let red = new URL('../../mock/img/red.png', import.meta.url).href
let yellow = new URL('../../mock/img/yellow.png', import.meta.url).href

let happy = new URL("../../mock/img/happy.png", import.meta.url).href
let smile = new URL("../../mock/img/smile.png", import.meta.url).href
let nothappy = new URL("../../mock/img/nothappy.png", import.meta.url).href
let total = Math.floor(Math.random() * (1000 + 1)+1)+1000
let random0  = Math.random()*126 
let random1  = Math.random()*128 
let random2  = Math.random()*126 
let random3  = Math.random()*126 

let totallist = Math.floor(Math.random() * (4000 + 1)+1)+1000
let satisfaction  = Math.floor(Math.random() * (2000 + 1)+1)+1000
let random  = Math.floor(Math.random() * (1000 + 1)+1)+1000
export default [
    {
        url: 'home',
        method: 'post',
        t(req) {
			const { num,income,increase  } = JSON.parse(req.body)
			return {
				code: 0,
				data: {
					schedule: [
						{
							num:num*2,
							total: num*5
						},
						{
							num: num*3,
							total: num*6
						},
						{
							num: num*4,
							total: num*8
						}
					],
					totalIncome:[
						{
							id:1,
							type:'income',
							url:blue,
        					title:'总收入',
							num:income*2,
							total,
							rate: (100*(income*2/total)).toFixed(2)
						},
						{
							id:2,
							type:'expense',
							url:green,
        					title:'总费用',
							num: income*2-(income-Math.floor(income/2)),
							total,
							rate: (100*((income*2-(income-Math.floor(income/2)))/total)).toFixed(2)
						},
						{
							id:3,
							type:'increase',
							url:red,
							title:'总增长',
							num: increase*1.5-increase,
							total,
							rate: (100*((increase*1.5-increase)/total)).toFixed(2)
						},
						{
							id:4,
							type:'rateReturn',
							url:yellow,
							title:'退回率',
							num: Math.abs(increase-income*2-income*2),
							total,
							rate: (100*(Math.abs(increase-income*2-income*2)/total)).toFixed(2)
						},
					]
				},
				success: true
			}
        }
    },
	{
        url: 'home/echartList',
        method: 'post',
        t(req) {
			const { startTime, endTime  } = JSON.parse(req.body)
			if(startTime&&endTime){
				console.log(startTime, endTime)
				let arr = [
					{
						id: 1,
						name: "邮件营销",
						day: []
					},{
						id: 2,
						name: "联盟广告",
						day:[]
					},{
						id: 3,
						name: "视频广告",
						day:[]
					},{
						id: 4,
						name: "直接访问",
						day: []
					},{
						id: 5,
						name: "搜索引擎",
						day: []
					}
				]
				for(var i = 0;i<arr.length;i++){
					for(var j =0 ;j<7;j++){
						arr[i].day.push({
							time:j==0?'周一':j==1?'周二':j==2?'周三':j==3?'周四':j==4?'周五':j==5?'周六':'周日',
							total: Math.floor(Math.random()*random0 )*total
						})
					}
				}
				return {
					code: 0,
					data: arr,
					success: true,
					message: '查询成功'
				}
			}else{
				return {
					code: 0,
					data: [],
					success: false,
					message: '查询失败'
				}
			}
			
        }
    },
	{url: 'home/overallData',
        method: 'post',
        t(req) {
			const { startTime, endTime  } = JSON.parse(req.body)
			let parseInttotal = totallist // 总数
			let parseIntSatisfaction = parseInt(satisfaction) // 五星
			let parseIntRandom =totallist -  parseIntSatisfaction-50// 三星
			// let  parseIntRandom4 = parseInt(random4)
			// console.log(totallist)
			
			console.log(parseIntSatisfaction)
				return {
					code: 0,
					data:{
						list:[
							{
								id:1,
								name:'今日成交数量',
								num: parseInt(random1)*4
							},
							{
								id:2,
								name:'昨日成交数量',
								num: parseInt(random1) *5
							},
							{
								id:3,
								name:'本月成交数量',
								num: parseInt(random1)* 15
							},
							{
								id:4,
								name:'累计成交量(年)',
								num: parseInt(random1)* 20
							}
						],
						money:[
							{
								id:1,
								name:'今日成交金额',
								num: parseInt(random1)*9
							},
							{
								id:2,
								name:'昨日成交金额',
								num: parseInt(random1) *10
							},
							{
								id:3,
								name:'本月成交金额',
								num: parseInt(random1)* 30
							},
							{
								id:4,
								name:'累计成交金额(年)',
								num: parseInt(random1)* 40
							}
						],
						payData:[
							{
								// id: 1,
								name: '微信',
								value: '40'
							},
							{
								// id: 2,
								name: '支付宝',
								value: '40'
							},
							{
								// id: 3,
								name: '银行卡',
								value: '20'
							}
						],
						satisfaction:[
							{
								name: '五星及以上评论',
								url: happy,
								total: parseInttotal,
								comment: parseIntSatisfaction,
								pec: '60%'
							},
							{
								name: '三星及以上评论',
								url: smile,
								total: parseInttotal,
								comment: parseIntRandom,
								pec: '39%'
							},
							{
								name: '二星及以下评论',
								url: nothappy,
								total: parseInttotal,
								comment: parseInttotal - parseIntSatisfaction - parseIntRandom,
								pec: '1%'
							}
						]
					},
					success: true,
					message: '查询成功'
				}
			
		}
	}
]
